void PixPort::_BoxBlur( char* inSrce, char* inDest, int inBoxWidth, int inWidth, int inHeight, int inSrceRowWidth, int inDestRowWidth, unsigned long* b, unsigned long inBackColor ) {
register unsigned long* bEnd;
register char *dest;
register unsigned long b1R, b1G, b1B, b2R, b2G, b2B, b3R, b3G, b3B, val, box9W, i, numerator;
register int x, half, useWidth;
i = inBoxWidth * inBoxWidth * inBoxWidth;
numerator = ( 1 << DENOM_SHIFT ) / ( i );
box9W = 9 * inBoxWidth; // 3 colors, 3 boxes
bEnd = b + box9W;
b1R = 0; b1G = 0; b1B = 0;
b2R = 0; b2G = 0; b2B = 0;
b3R = i >> 1; b3G = b3R; b3B = b3R; // round up when > .5
for ( i = 0; i < box9W; i++ ) {
b[ i ] = 0;
}
half = 3 * inBoxWidth / 2 - 1;
inSrce += P_SZ * half;
useWidth = inWidth - half - inBoxWidth % 2;
// Go thru row by row in the source img
for ( ; inHeight > 0; inHeight-- ) {
// Go thru the row
dest = inDest;
for ( x = - half - 5; x < inWidth; x++ ) {
// Maintain the circular buffer
if ( b == bEnd )
b -= box9W;
// p = fetch next pix from b1
if ( x >= 0 && x < useWidth ) {
val = *( (PIXTYPE*) inSrce );
inSrce += P_SZ; }
else
val = inBackColor;
// p' += new pix - end pix and store new pix
i = val >> REDSHIFT; b1R += i - b[0]; b[0] = i;
i = (val >> GRNSHIFT) & COLMASK; b1G += i - b[1]; b[1] = i;
void PixPort::_BoxBlur( char* inSrce, char*, int inBoxWidth, int inWidth, int inHeight, int inSrceRowWidth, int, char* b, unsigned long inBackColor ) {
register char *bEnd;
register unsigned long b1R, b1G, b1B, b2R, b2G, b2B, b3R, b3G, b3B, val, box9W, i, denom;
register int x, half, useWidth;
denom = inBoxWidth * inBoxWidth * inBoxWidth;
box9W = 36 * inBoxWidth; // 3 colors, 3 boxes, 4 bytes per long
bEnd = b + box9W;
b1R = 0; b1G = 0; b1B = 0;
b2R = 0; b2G = 0; b2B = 0;
b3R = 0; b3G = 0; b3B = 0;
for ( i = 0; i < 9 * inBoxWidth; ) {
*((UL*) b + i) = 0; i++;
}
half = 3 * inBoxWidth / 2 - 1;
inSrce += P_SZ * half;
useWidth = inWidth - half - inBoxWidth % 2;
// Go thru row by row in the source img
for ( ; inHeight > 0; inHeight-- ) {
for ( x = - half - 5; x < inWidth; x++ ) {
// Maintain our circular buffer
if ( b == bEnd )
b -= box9W;
// p = fetch next pix from b1
if ( x >= 0 && x < useWidth ) {
val = *( (PIXTYPE*) inSrce );}
else
val = inBackColor;
// p' += new pix - end pix and store new pix
i = val >> REDSHIFT; b1R += i - *((UL*)b); *((UL*)b) = i; b += 4;
i = (val >> GRNSHIFT) & COLMASK; b1G += i - *((UL*)b); *((UL*)b) = i; b += 4;
i = val & COLMASK; b1B += i - *((UL*)b); *((UL*)b) = i; b += 4;